cmake_minimum_required(VERSION 3.14)
project(usockets)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set(CMAKE_AUTOUIC ON)
#set(CMAKE_AUTOMOC ON)
#set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)

if(WIN32)
    add_definitions(
        -DWIN32
        -D_WIN32_WINNT=0x0A00
        -DYAML_CPP_STATIC_DEFINE
        -D_CRT_SECURE_NO_WARNINGS
        #-DWITH_ASIO
        #-DLIBUS_USE_ASIO
        #-DLIBUS_USE_OPENSSL
        -DLIBUS_NO_SSL
        -DLIBUS_USE_LIBUV
    )
else()
    add_definitions(
        #-DWITH_ASIO
        #-DWITH_OPENSSL
        -DLIBUS_NO_SSL
        -DLIBUS_USE_LIBUV
        #-DLIBUS_USE_OPENSSL
    )
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

#设置win32运行时库
if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_MSVC_RUNTIME_LIBRARY_LINKAGE_Debug "MultiThreadedDebug$<$<CONFIG:Debug>:_DLL>")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY_LINKAGE_Release "MultiThreaded$<$<CONFIG:Release>:_DLL>")
endif()
endif()

if(WIN32)
include_directories(../libuvc/include/)
include_directories(./src)
include_directories(../libuv/include/)
include_directories(../OpenSSL/include/)
#include_directories(../boost_1_82_0_build/include/boost-1_82/)
else()

endif()

add_library(
    usockets STATIC 

    #crypto
    #./src/crypto/openssl.c
    #./src/crypto/sni_tree.cpp

    #internal
    #./src/internal/eventing/asio.h
    #./src/internal/eventing/epoll_kqueue.h
    #./src/internal/eventing/gcd.h
    ./src/internal/eventing/libuv.h
    ./src/internal/networking/bsd.h
    ./src/internal/internal.h
    ./src/internal/loop_data.h

    #eventing
    #./src/eventing/asio.cpp
    #./src/eventing/epoll_kqueue.c
    #./src/eventing/gcd.c
    ./src/eventing/libuv.c

    #io_uring
    #./src/io_uring/internal.h
    #./src/io_uring/io_context.c
    #./src/io_uring/io_loop.c
    #./src/io_uring/io_socket.c
    

    ./src/bsd.c
    ./src/context.c
    ./src/libusockets.h
    ./src/loop.c
    ./src/quic.h
    ./src/quic.c
    ./src/socket.c
    ./src/udp.c
)
